<template>
  <page-meta
    :page-style="pageStyle"
  />
  <view :class="['all-page', 'is-template-3']">
    <x-navigation-bar v-if="inFullScreen" :placeholder="false" background="transparent" :subscribeNode="7" :page-id="query.pageId" :storeId="pageInfo.storeId"/>
    <x-time-out v-if="isTimeOut" @retry="handleRetryPage" />
    <template v-if="isDeleted">
      <!--页面被删除-->
      <p-deleted-box v-if="isDeleted" :productId="pageInfo.productId" class="p-deleted-box" />
    </template>
    <template v-else>
      <!--返回百度按钮-->
      <p-baidu v-if="isShowBaidu" :referrerInfo="referrerInfo" />
      <x-skeleton type="detail" v-if="!isLoad" />
      <!--轮播图-->
      <p-swiper v-if="indexPic || !isLoad" :index-pic="indexPic" :index-video="indexVideo" :isZindex="!isLoad" is-video @fullscreenchange="fullscreenchange">
        <!-- 悬浮跑马灯 -->
        <view v-if="!isScanScene && carouselList && pageModule.marquee && pageModule.marquee.fixed" class="m-fixed-carousel">
          <x-carousel-fixed :list="carouselList" />
        </view>
      </p-swiper>

      <!-- 商品价格 -->
      <template v-if="!isScanScene && pageInfo">
        <p-price :query="query"/>
      </template>

      <p-slogan v-if="isTemplate3" :sales="sales" />

      <!-- 轮播图下面价格部分 -->
      <view class="goods-content">
        <!-- 品牌 -->
        <view class="brand">
          <view class="lf">
            <view ref="page-title" class="_title" v-if="pageInfo">
              {{ pageInfo.pageProductTitle }}
            </view>
          </view>
        </view>
        <view class="product-selling-point" style="display: flex">
          <view class="_introduce">{{ pageInfo.pageSellingPoint || '' }}</view>
        </view>
        <!-- 品牌 -->
        <view class="store" v-if="brandInfo">
          <view class="_logo">
            <x-image :src="formatOss(brandInfo.brandLogo,100)" />
          </view>
          <view class="_name">{{ brandInfo.brandName }}</view>
          <view class="_vertical-line" />
          <view class="_introduce">{{ brandInfo.brandDesc }}</view>
        </view>
      </view>

      <p-hot-sale-notice v-if="isTemplate3" />
      <x-delivery :productSafeguard="productInfo.productSafeguard"/>

      <!-- 跑马灯 -->
      <view v-if="!isScanScene && carouselList && pageModule.marquee && pageModule.marquee.styleType !== 2" style="margin-top: 20rpx">
        <x-carousel :list="carouselList" :header="carouselHeader" is-new-template button-text="马上抢" @change="showBuy" />
      </view>

      <view v-if="isTemplate3" class="gray-box">
        <view v-if="productInfo.skuMode !== 1" class="li-item" @click="showOrderModal">
          <p-middle-sku title="选择" selected-sku="" :detail="productInfo" :productId="pageInfo.productId" />
        </view>
        <view v-if="pageModule.servicePromise && safeguardList && safeguardList.length > 0" class="li-item">
          <p-service
            title="保障"
            :attr-list="safeguardList"
            @click.native="serviceVisible = true"
          />
        </view>
        <view class="li-item">
          <p-specifications :attr-list="productInfo.productAttrValues" />
        </view>
      </view>

      <!-- 用户评价 -->
      <template v-if="!isScanScene && pageModule.productComment && pageInfo">
        <p-apprise :product-id="pageInfo.productId" :comment-type="productInfo.productComment" :new-label="productInfo.commentLabelList" :label="productInfo.commentLabelSelected" :min="3" :is-template-3="isTemplate3" />
      </template>

      <!-- 问大家 -->
      <p-ask v-if="!isScanScene && pageInfo" is-new-template :product-id="pageInfo.productId" />

      <!-- 跑马灯 -->
      <view v-if="!isScanScene && carouselList && pageModule.marquee && pageModule.marquee.styleType === 2">
        <x-carousel-horizontal :header="carouselHeader" :list="carouselList" is-new-template :sales="sales" @buy="showBuy" />
      </view>

      <!-- 店铺 -->
      <p-store
        v-if="pageInfo.storeId"
        :storeEntrance="pageModule.storeEntrance"
        :storeRecommend="pageModule.storeRecommend"
        :storeId="pageInfo.storeId"
        :storeInfo="storeInfo"
        :productId="pageInfo.productId"
      />

      <!--商品介绍/规格信息-->
      <p-details
        v-if="productInfo"
        :product-attr="productInfo.productAttrValues"
        :product-images="productImages"
        title="宝贝详情"
      />
      <p-qualifications v-if="productInfo && productInfo.qualificationPics" :qualificationPics="productInfo.qualificationPics" />

      <!-- 填写订单 -->
      <view v-if="isShowFormStyle" id="form-order" ref="form-order" class="form-order">
        <view class="title">填写订单</view>
        <view class="pop_info">
          <p-order-info
            ref="orderInfoDetail"
            v-if="productInfo && isGetCouponList"
            :query="query"
            :detail="productInfo"
            :page-id="query.pageId"
            :product-id="pageInfo.productId"
            :store-info="storeInfo"
            :animate-end="beforeAnimateEnd"
            :gift="productGiftInfo"
            :discount-price-sum.sync="discountPriceSum"
            :is-new-template="isNewTemplate"
            :address-info.sync="addressInfo"
            :is-template-3="isTemplate3"
            :isShowFormStyle="isShowFormStyle"
            :groupsDetail="groupsDetail"
            is-adv
          />
        </view>
      </view>

      <view class="company-info">
        <view v-if="storeInfo.companyName"><text class="store-name" @click="handleToBusiness">商家： {{ storeInfo.companyName || '' }} | {{ storeInfo.companyAddress || '' }}</text></view>
        <view>商品及服务相关售后，请于微信小程序【{{appName}}】中联系店铺客服获取</view>
        <view v-if="storeInfo.channelCompanyName">【{{storeInfo.channelCompanyName}}】仅提供技术支持 | 4001005802</view>
        <view v-if="storeInfo.channelCompanyName">{{storeInfo.channelCompanyName === '杭州微数数码科技有限公司' ? '浙ICP备2023006219号-2' : '浙ICP备2021000297号-1'}}</view>
      </view>
      <!-- 底部固定栏 -->
      <template v-if="isTemplate3">
        <view class="page-placeholder"></view>
        <view :class="['new-footer', hideFooter ? 'is-hide' : '']">
          <p-fixed-discount v-if="!isScanScene" :price="discountPriceSum || totalDiscount" :style-type="2" />
          <x-send-coupon v-if="!isSendCoupon && couponSendList && couponLoaded" :coupon="couponSendList" @sendcoupon="handleClickBuyButton">
            <p-fixed-button :detail="pageModule.bottomButton" :store-info="storeInfo" :session-from="sessionFrom" :share-customer-data="shareCustomerData" />
          </x-send-coupon>
          <p-fixed-button style="margin-bottom: 20px" v-else :query="query" :pageId="query.pageId" :detail="pageModule.bottomButton" :store-info="storeInfo" :session-from="sessionFrom" :share-customer-data="shareCustomerData" @click="handleClickBuyButton"/>
        </view>
      </template>

      <!-- 悬浮下订单层 -->
      <x-drawer :visible.sync="isShowFormOrder" isScroll>
        <view
          v-if="isShowFormOrder && productInfo && isGetCouponList"
          :scroll-y="true"
          class="pop_order-info"
        >
          <scroll-view class="pop_info" :scroll-y="true">
            <p-order-info
              ref="orderInfo"
              is-drawer
              :query="query"
              :detail="productInfo"
              :page-id="query.pageId"
              :product-id="pageInfo.productId"
              :store-info="storeInfo"
              :animate-end="beforeAnimateEnd"
              :gift="productGiftInfo"
              :discount-price-sum.sync="discountPriceSum"
              :is-template-3="isTemplate3"
              :isShowFormStyle="isShowFormStyle"
              :groupsDetail="groupsDetail"
              is-adv
            />
          </scroll-view>
        </view>
      </x-drawer>

      <!--分享海报-->
      <view class="p-poster" catchtouchmove="true" v-if="posterVisible">
        <view class="p-container" v-if="posterLoad">
          <view class="close-icon" @click="closePoster">
            <x-icon name="icon-003" size="54" color="#CCCCCC"/>
          </view>
          <view class="_img">
            <x-image :src="posterImage" mode="widthFix" />
          </view>
          <view class="save-poster" @click="saveImage">
            保存图片
          </view>
        </view>
      </view>

      <!--分享-->
      <p-drawer-share v-if="shareVisible" :visible.sync="shareVisible" :detail="shareData" from="advertising" @shareImage="shareImage" />
      <!--服务信息弹框-->
      <p-drawer-service v-if="serviceVisible" :visible.sync="serviceVisible" :serveList="safeguardList" />
      <!--聚合页弹窗-->
      <x-groups-modal v-if="groupsVisible && popupStatus" :visible.sync="groupsVisible" :detail="groupsDetail" :coupon="allCouponSend" :is-primary-page="isPrimaryPage" @click="handleGroupsModal" />
      <x-countdown v-if="query.discountAmount" :time="299000" auto @change="handleCountdownChange"/>
      <!--新挽留弹窗-->
      <x-pop-ups
        v-if="payCancelTwoVisible && exitPopupList.length > 0 && isShowExitPopup"
        :visible.sync="stayPopupVisible"
        @ready="scrollToFormOrder"
        @confirm="onDiscountPay"
      />
      <!--超值补贴及优惠券领取弹框-->
      <p-subsidy-modal
        v-if="showSubsidy && !isEmbedded"
        :allCouponSend="allCouponSend"
        :query="query"
        @onSendCoupon="onCustomEvent"
        @onCloseCoupon="onCloseCustomEvent"
        @close="handleCloseSubsidyModal"
      />
      <!--优惠券领取弹框-->
      <p-coupon-drawer
        v-else-if="isShowCoupon && !isEmbedded"
        :couponStyleImageUrl="couponStyleImageUrl"
        :allCouponSend="allCouponSend"
        :query="query"
        @onSendCoupon="onCustomEvent"
        @onCloseCoupon="onCloseCustomEvent"
      />

      <p-evoke v-if="evokeVisible" :query="query" :carousel-list="carouselList" @close="evokeVisible = false" />
    </template>
  </view>
</template>

<script>
import { mapState } from 'vuex';
import $sr from '@/utils/x-sr';
import $config from '@/config';
import XNavigationBar from '@/components/x-navigation-bar';
import XImage from '@/components/x-image';
import XIcon from '@/components/x-icon';
import XSkeleton from '@/components/x-skeleton';
import XCarousel from '@/components/x-carousel';
import XCarouselHorizontal from '@/components/x-carousel-horizontal';
import XCarouselFixed from '@/components/x-carousel-fixed';
import XGroupsModal from '@/components/x-groups-modal';
import XDrawer from '@/components/x-drawer';
import XCountdown from '@/components/x-countdown';
import XTimeOut from '@/components/x-time-out';
import XPopUps from '@/components/x-pop-ups';
import XSendCoupon from '@/components/x-send-coupon';

import PSwiper from './components/p-swiper';
import PPrice from './components/p-price';
import PDetails from './components/p-details';
import POrderInfo from './components/p-order-info';
import PCouponDrawer from './components/p-coupon-drawer';
import PFixedDiscount from './components/p-fixed-discount';
import PSubsidyModal from './components/p-subsidy-modal';
import PSpecifications from './components/p-specifications';
import PService from './components/p-service';
import PMiddleSku from './components/p-middle-sku';
import PSlogan from './components/p-slogan';
import PDrawerShare from './components/p-drawer-share';
import PDrawerService from './components/p-drawer-service';
import PApprise from './components/p-apprise';
import PStore from './components/p-store';
import PDeletedBox from './components/p-deleted-box';
import PHotSaleNotice from './components/p-hot-sale-notice/index.vue';
import PFixedButton from './components/p-fixed-button';
import PAsk from './components/p-ask';
import PEvoke from './components/p-evoke';
import XDelivery from '../../components/x-delivery/index.vue';
import PBaidu from './components/p-baidu/index.vue';
import PQualifications from './components/p-qualifications/index.vue';

// 相交区域
let ObserverForm = null;
// 页面滑动位置
let pageScrollTop = 0;
// 重试次数
let HTTP_RETRY_COUNT = 0;

export default {
  name: 'Advertising',
  components: {
    PQualifications,
    PBaidu,
    XDelivery,
    XCountdown,
    XNavigationBar,
    XSkeleton,
    XCarousel,
    XCarouselHorizontal,
    XCarouselFixed,
    XGroupsModal,
    XDrawer,
    XIcon,
    XImage,
    XTimeOut,
    XPopUps,
    XSendCoupon,
    PPrice,
    PDetails,
    POrderInfo,
    PDeletedBox,
    PStore,
    PFixedDiscount,
    PDrawerShare,
    PDrawerService,
    PApprise,
    PSwiper,
    PCouponDrawer,
    PSubsidyModal,
    PSpecifications,
    PService,
    PMiddleSku,
    PSlogan,
    PHotSaleNotice,
    PFixedButton,
    PAsk,
    PEvoke
  },
  props: {},
  data() {
    return {
      appName: $config.appName,
      // 第三方开发平台
      isOpenApp: $config.isOpen,
      query: {},
      // 商详页无数据，跳转404错误页面
      isDeleted: false,
      // 超时或api响应错误时
      isTimeOut: false,
      isLoad: false,
      hideFooter: false,
      // 分享海报
      posterVisible: false,
      posterImage: '',
      posterLoad: false,
      // 分享弹框
      shareVisible: false,
      // 服务弹框
      serviceVisible: false,
      // 分享出去的海报信息
      shareData: {},
      //  店铺信息
      storeInfo: null,
      isCouponPrice: false, // 是否可用优惠价
      // 是否进入全屏
      inFullScreen: true,
      // 页面是否滚动过
      scrolled: false,
      // 客服按钮卡片信息等
      shareCustomerData: {},
      sessionFrom: null,
      // 品牌信息
      brandInfo: null,
      // 聚合页弹窗
      groupsVisible: false,
      groupsDetail: null,
      // 优惠券列表是否已经获取过
      isGetCouponList: false,
      // 当前页面挽留弹窗状态
      stayPopupVisible: false,
      popupVisible: true,
      // 是否显示过表单
      StartShowFrom: false,
      // 悬浮表单
      isShowFormOrder: false,
      // 挽留弹框动效即将结束前
      beforeAnimateEnd: false,
      // 当前挽留弹框是否显示过
      isShowExitPopup: true,
      // 返回顶部
      toTop: false,
      // 错误情况下轮询获取信息定时器
      getPageDetailTimeout: null,
      getProductDetailTimeout: null,
      couponSendList: null,
      couponLoaded: false,
      // 优惠券配置图
      couponStyleImageUrl: '',
      // 显示/隐藏交互优惠券弹框
      couponDrawerVisible: true,
      // 优惠总金额
      discountPriceSum: 0,
      // 下单有礼数量
      productGiftInfo: 0,
      // 显示/隐藏超级补贴弹框
      superSubsidyVisible: true,
      // 自动唤起好物推荐
      evokeVisible: false,
      // 表单信息
      addressInfo: null,
      evokeTimer: null,
      isShowCompany: false,
      // 百度返回按钮
      isShowBaidu: false,
      referrerInfo: null,
      apiCategory: wx.getEnterOptionsSync().apiCategory
    };
  },
  computed: {
    ...mapState({
      // app onShow 场景值
      scene: state => state['pages'].scene,
      // 设备信息
      windowInfo: state => state['product'].windowInfo,
      // 用户挽留弹框配置的优惠数组
      exitPopupList: state => state['pages'].exitPopupList,
      // 用户挽留弹框配置的优惠展示过的下标
      exitPopupIndex: state => state['pages'].exitPopupIndex,
      clearStoreStorage: state => state['pages'].clearStoreStorage,
      // 投放页面初始数据
      pageQuery: state => state['pages'].pageQuery,
      // 页面信息
      pageInfo: state => state['product'].pageDetail,
      // 页面模块
      pageModule: state => state['product'].pageModule || {},
      // 商品信息
      productInfo: state => state['product'].productDetail,
      // 服务承诺
      safeguardList: state => state['product'].safeguardList,
      // 跑马灯数据
      carouselList: state => state['product'].carouselList,
      carouselTitle: state => state['product'].carouselTitle,
      // 返回出优惠金额弹框
      payCancelTwoVisible: state => state['pages'].payCancelTwoVisible,
      // 一键开启/关闭视频号场景挽留弹框
      popupStatus: state => state['pages'].popupStatus,
      // 当前商品关联的可领取优惠券，只支持批次领取，最多10个
      allCouponSend: state => state['product'].couponSend,
      // 当前是否领取过优惠券
      isSendCoupon: state => state['product'].isSendCoupon,
      // 商品主图
      indexPic: state => state['product'].resourceModule?.indexPic,
      // 主图视频
      indexVideo: state => state['product'].resourceModule?.indexVideo,
      // 商品图片资源
      productImages: state => state['product'].resourceModule?.detailPic?.picList || [],
      // 超值补贴模块
      superSubsidyModule: state => state['product'].pageModule?.superSubsidy,
      // 页面最低价格
      pagePrice: state => state['product'].pageDetail?.pagePrice,
      // 页面单买价
      pageHighPrice: state => state['product'].pageDetail?.pageHighPrice,
      // 用户当前选择的优惠券信息
      userSelectCoupon: state => state['product'].userSelectCoupon,
      // 订单未支付的优惠弹框
      aggregatePage: state => state['product'].pageModule?.aggregatePage,
      // 未支付与挽留弹框状态
      payCancelTwoVisibleAgain: state => state['pages'].payCancelTwoVisibleAgain,
      // 好物推荐
      topPicks: state => state['product'].pageModule?.topPicks,
      // 用户下单信息
      orderCountInfo: state => state['pages'].orderCountInfo,
      // 腾讯去除挽留逻辑
      isTxOline: state => state['pages'].isTxOline
    }),
    // 是否显示悬浮客服
    isShowCustomerService() {
      return !this.hideFooter && this.pageModule?.customerService;
    },
    sales() {
      if (!this.isScanScene && this.pageModule.hotSales) {
        const sum = (this.pageInfo?.pageSales || 0) + this.pageModule.hotSales.value;
        const val = this.$tools.formatNumber(sum);
        return `${this.$tools.numberFormat(val)}${val >= 10000 ? '+' : ''}人已购买`;
      } else {
        return '';
      }
    },
    // 跑马灯顶部信息
    carouselHeader() {
      if (this.pageModule?.marquee) {
        return {
          title: this.carouselTitle,
          desc: this.pageModule.marquee.title
        };
      } else {
        return null;
      }
    },
    isShowFormStyle() {
      return this.pageModule?.formStyle?.value === 2;
    },
    // 显示固底按钮
    isShowBottomButton() {
      return this.pageModule?.bottomButton;
    },
    pageStyle() {
      return `overflow: ${(this.isShowFormOrder || this.isShowCoupon) ? 'hidden' : 'auto'};background: '#ffffff'}`;
    },
    // 是否展示优惠券领取
    isShowCoupon() {
      return this.couponDrawerVisible &&
        this.allCouponSend &&
        !this.isSendCoupon &&
        !this.payCancelTwoVisible &&
        !['stay', 'groups', '1004', '1013', '1014', '1018', '1019', '1030'].includes(this.query.source);
    },
    // 挽留状态
    isStay() {
      return ['stay'].includes(this.query.source);
    },
    // 是否为主推商品页
    isPrimaryPage() {
      return ['1030'].includes(this.query.source);
    },
    showSubsidy() {
      return this.pageModule?.superSubsidy && this.superSubsidyVisible && !this.currentExitPopup && !this.query?.discountAmount && !this.isFromCouponCards;
    },
    // 当前挽留弹窗数据
    currentExitPopup() {
      return this.exitPopupList?.length ? this.exitPopupList[this.exitPopupIndex - 1] : null;
    },

    isFromCouponCards() {
      return ['1008'].includes(this.query.source);
    },

    isTemplate3() {
      return this.pageInfo?.pageTemplate === 3;
    },
    // 当前挽留弹窗优惠信息
    currentExitPopupAmount() {
      if (this.currentExitPopup) {
        return this.currentExitPopup.discountAmount;
      }
      return 0;
    },
    // 超值补贴
    isSuperSubsidy() {
      return this.superSubsidyModule && this.superSubsidyModule.value;
    },
    // 超值补贴金额
    superSubsidyAmount() {
      return (this.isSuperSubsidy && !this.isFromCouponCards) ? this.superSubsidyModule.value : 0;
    },
    // 直降金额：单买价-拼单价
    directReductionAmount() {
      return this.$tools.formatNumber(this.pageHighPrice - this.pagePrice) || 0;
    },
    discountAmount() {
      let amount = 0;
      if (this.isFromCouponCards) {
        return 0;
      }
      if (this.payCancelTwoVisibleAgain) {
        // 挽留优惠金额
        amount = this.currentExitPopupAmount;
      } else if (this.query?.discountAmount) {
        // url参数上带的优惠金额
        amount = Number(this.query.discountAmount);
      } else if (this.query?.useDiscount && this.aggregatePage?.discountAmount) {
        // url参数上带的需要使用最大优惠金额的标识时，使用最大优惠金额
        amount = Number(this.aggregatePage?.discountAmount);
      }
      return this.$tools.formatNumber(amount) || 0;
    },
    totalDiscount() {
      let discountPriceSum = this.directReductionAmount;
      if (this.discountAmount) {
        discountPriceSum += this.discountAmount;
      } else if (this.superSubsidyAmount) {
        discountPriceSum += this.superSubsidyAmount;
      } else if (this.userSelectCoupon) {
        discountPriceSum += this.userSelectCoupon.couponAmount;
      }
      return this.$tools.formatNumber(discountPriceSum);
    },
    // 当为扫码进入，且无td参数时
    isScanScene() {
      return [1011, 1012, 1013, 1025, 1031, 1032, 1047, 1048, 1049].includes(this.scene) && ![1, '1'].includes(this.query.td);
    },
    isEmbedded() {
      return $config.appletType === 2;
    }
  },
  watch: {
    payCancelTwoVisible(value) {
      this.stayPopupVisible = value;
    }
  },
  // 滚动页面
  onPageScroll(e) {
    // this.$refs['x-fixed'].scrollTab(e);
    this.handlePageScroll(e.scrollTop);

    // 是否展示返回顶部
    this.toTop = e.scrollTop > this.windowInfo.windowHeight;
  },
  onReady() {
    this.createObserver();
    // 防止数据未加载出来导致无法获取进度
    setTimeout(() => {
      this.createObserver();
    }, 1000);
  },
  async onLoad(query, option) {
    let source = query.source || 'default';
    this.query = query;
    if (query.scene) { // 从小程序码进入
      const scene = this.$tools.param2Object(query.scene);
      this.query.pageId = scene.id;
      source = 'shareCode';
    } else {
      this.query.pageId = query.pageId || query.id;
    }
    // 获取小程序进入场景和参数
    const launchOptions = uni.getLaunchOptionsSync();
    // console.log(launchOptions, 'launchOptions');
    if (launchOptions.scene === 1069) {
      this.isShowBaidu = true;
      this.referrerInfo = launchOptions.referrerInfo;
    }
    this.$XTrack('launchOptions', launchOptions);
    // 重置store中的部分数据
    pageScrollTop = 0;
    // 重置计数
    HTTP_RETRY_COUNT = 1;
    this.$store.dispatch('pages/setData', {
      comboIndex: 0,
      payCancelTwoVisibleAgain: false,
      isConfirmPopup: false
    });
    if (!this.query.source || !['stay', 'groups', '1004', '1018', '1019', '1025', '1028', '1029', '1030', '1031'].includes(this.query.source)) {
      this.$store.dispatch('product/reset');
      this.$store.dispatch('pages/fetchAppStore');
    }
    // 获取模块配置信息
    if (this.isStay) {
      this.isLoad = true;
      if (['1', '6', '7', '8', '9', '10'].includes(this.query.styleType)) {
        await this.getPageDetail(query);
      }
    } else {
      await this.getPageDetail(query);
    }
    this.showEvoke();
    this.$XTrack('source', source);
    this.$XTrack('onStart');
  },
  async onShow(options) {
    const {
      masterAppId,
      masterOpenId,
      masterUnionId
    } = this.query;
    if (masterAppId) {
      this.query.fromMasterAppId = masterAppId;
    }
    await this.$store.dispatch('user/login', {
      masterAppId,
      masterOpenId,
      masterUnionId
    });
    this.scrolled = false; // 重置滚动标识
    // 标识页面状态
    this.setPreviousPath();

    const { apiCategory, referrerInfo, scene } = wx.getEnterOptionsSync();
    // const newOptions = wx.getEnterOptionsSync();
    // const launchOptions = wx.getLaunchOptionsSync();
    // console.log(referrerInfo, apiCategory, 33333);
    const isFromMini = uni.getStorageSync('embedded-mini-program-data') || 0;

    if (referrerInfo && [1037, 1038].includes(scene) && isFromMini === 1) {
      if (referrerInfo.extraData) {
        const extraData = referrerInfo.extraData;
        setTimeout(() => {
          // console.log(444444, this.$refs.orderInfo, extraData);
          const thisOrder = this.$refs.orderInfo;

          // 如果有下单未支付，并且有下单未支付金额
          if (extraData.paramsId) {
            this.$http({
              login: true,
              url: '/order/order/params',
              method: 'GET',
              data: {
                paramsId: extraData.paramsId
              }
            }).then(async(res) => {
              // console.log(res, 'res---------', JSON.parse(res.data).json);
              thisOrder.payOrderInfo = JSON.parse(res.data).json;
              // console.log(thisOrder.userSelectCoupon, thisOrder.payCancelPopDiscountAmount, thisOrder.discountAmount, thisOrder.exitPopupList, '999999');

              if (thisOrder && extraData.payCancelTwoVisible && thisOrder.payOrderInfo) {
                thisOrder.payCancelTwoVisible = true;
                thisOrder.repay = true;
              } else if (extraData.payCancelVisible) {
                if (!thisOrder.userSelectCoupon && thisOrder.payCancelPopDiscountAmount > thisOrder.discountAmount || 0) {
                  thisOrder.payCancelTwoVisible = true;
                  // 取消支付，可以使用优惠金额支付了
                  thisOrder.repay = true;
                } else {
                  thisOrder.payCancelVisible = true;
                }
              }
              // 取消下单未支付操作
              if (thisOrder && extraData.handleCancelPayPop === 1) {
                thisOrder.handleCancelPayPop();
              }
            });
            return;
          }
        }, 1000);
        const { orderId, payStatus } = extraData;
        if (orderId && payStatus === 1) {
          this.$store.dispatch('message/requestSubscribeMessage', {
            subscribeNode: 1,
            subscribeType: 1,
            subscribeContent: this.query.pageId,
            storeId: this.storeInfo?.storeId
          }).then(() => {
            uni.reLaunch({
              url: `/packages/order/pay-status/index?orderId=${orderId}`
            });
          }).catch(() => {
            uni.reLaunch({
              url: `/packages/order/pay-status/index?orderId=${orderId}`
            });
          });
        }
      }
    }
  },
  onHide() {
    // 离开页面后取消定时器
    if (this.getPageDetailTimeout) {
      this.$XTrack('clearTimeout', {
        fun: 'getPageDetailTimeout',
        on: 'onHide'
      });
      clearTimeout(this.getPageDetailTimeout);
    }
    if (this.getProductDetailTimeout) {
      this.$XTrack('clearTimeout', {
        fun: 'getProductDetailTimeout',
        on: 'onHide'
      });
      clearTimeout(this.getProductDetailTimeout);
    }
    if (this.evokeTimer) {
      clearTimeout(this.evokeTimer);
    }
    // 页面加载之后，向数据团队上报特定消息
    this.$store.dispatch('pages/fetchReportViewAttr', this.query);
  },
  onUnload() {
    // 离开页面后取消定时器
    if (this.getPageDetailTimeout) {
      this.$XTrack('clearTimeout', {
        fun: 'getPageDetailTimeout',
        on: 'onUnload'
      });
      clearTimeout(this.getPageDetailTimeout);
    }
    if (this.getProductDetailTimeout) {
      this.$XTrack('clearTimeout', {
        fun: 'getProductDetailTimeout',
        on: 'onUnload'
      });
      clearTimeout(this.getProductDetailTimeout);
    }
    if (ObserverForm) ObserverForm.disconnect();
    // 页面加载之后，向数据团队上报特定消息
    this.$store.dispatch('pages/fetchReportViewAttr', this.query);
    // 清除当前场景值
    uni.setStorage({
      key: 'embedded-mini-program-data',
      data: 0
    });
  },
  // 分享转发
  onShareAppMessage() {
    // 分享统计
    const { pageId } = this.query;
    this.$store.dispatch('product/setShareCount', {
      pageId
    });
    const path = `/pages/advertising/index?pageId=${pageId}&source=share`;
    this.$XTrack('onShareAppMessage');
    return {
      title: this.pageInfo.pageProductTitle,
      path
    };
  },
  methods: {
    numberFormat(val) {
      return this.$tools.numberFormat(val);
    },
    formatZero(val) {
      return this.$tools.formatZero(val);
    },
    // 格式化图片
    formatOss(url) {
      return this.$tools.formatOss(url);
    },
    getCurrentPath() {
      const currPath = ['/pages/advertising/index'];
      const query = this.query;
      // 订阅消息场景获取
      const params = this.$tools.object2param(query);
      if (params) currPath.push(params);
      return currPath.join('?');
    },
    // 获取模块配置信息
    async getPageDetail(query) {
      // console.log('1111111', query);
      const params = {
        pageId: query.pageId,
        source: query.source,
        promotionScene: this.scene,
        pageUrl: this.getCurrentPath()
      };
      // 必要参数校验
      if (!params.pageId) {
        this.isDeleted = true;
        this.isLoad = true;
        return false;
      }
      await this.$store.dispatch('product/getPageDetail', params).then((res) => {
        // 成功之后，重置计数
        HTTP_RETRY_COUNT = 1;
        const { pageDetail, pageModule } = res;
        const { pageStatus, popupStatus, pageId, storeId, productId, immersiveVideoUrl } = pageDetail || {};
        if (!res || pageStatus === 2) {
          // pageStatus	int	1-已上架（投放中）；2-已下架
          this.isDeleted = true;
          this.isLoad = true;
        } else {
          // 当为扫码场景时，直接返回首页
          if (this.isScanScene) {
            this.$store.dispatch('pages/setData', {
              previousStatus: 99
            });
          } else if (!this.popupStatus) {
          // 当前场景值为视频号1228时，可用挽留弹窗状态调整为不可用
          // 当挽留弹框为不可用状态时，根据店铺视频号弹窗配置再进行重置
            this.$store.dispatch('pages/setData', {
              popupStatus: popupStatus === 1
            });

            // 视频号场景的时候、开关关闭的时候，直接返回到首页去
            if (!popupStatus) {
              this.$store.dispatch('pages/setData', {
                previousStatus: 99
              });
            }
          }

          // 获取商品信息后 获取店铺信息
          this.getStoreInfo();

          // 获取商品详情数据
          this.getProductDetail(pageDetail);
          // 新互动优惠券弹框
          if (pageModule.couponWxStyle) {
            this.couponStyleImageUrl = pageModule.couponWxStyle.imageUrl;
          }

          // 只在source为空的时候初始化一次数据
          const pageQuery = {
            ...(this.pageQuery || {})
          };
          if (!query.source) {
            Object.assign(pageQuery, {
              pageId,
              storeId,
              productId,
              immersiveVideoUrl
            });
          }

          // 交易完成页查看订单按钮
          this.$store.dispatch('pages/setData', {
            pageQuery,
            isShowOrderButton: !!pageModule.orderEntrance
          });

          // 页面后退的优惠弹框类型
          if (pageModule.exitPopup) {
            this.exitPopupValue = pageModule.exitPopup.value;
          }

          // 聚合页信息
          if (pageModule.aggregatePage) {
            const { pageType, discountAmount } = pageModule.aggregatePage;
            // 单品页自己跳自己，聚合页跳动态生成页
            this.$store.dispatch('pages/setData', {
              groupsInfo: {
                pageType,
                discountAmount,
                pageId: this.query.pageId
              }
            });
          } else {
            this.$store.dispatch('pages/setData', {
              groupsInfo: null
            });
          }

          // 埋点
          try {
            const pageConfig = {
              groupsInfo: pageModule.aggregatePage ? {
                pageType: pageModule.aggregatePage.pageType
              } : null,
              // 挽留配置
              exitPopup: pageModule?.exitPopup?.list || [],
              // 聚合页
              aggregatePage: pageModule?.aggregatePage || '',
              // 一键开启/关闭视频号场景挽留弹框
              popupStatus
            };
            this.$XTrack('logsMapIndex', {
              pageConfig
            });

            const { source, discountAmount } = this.query;
            if (!['stay', 'groups', '1018', '1019'].includes(source)) {
              let list = pageModule?.exitPopup?.list || [];
              if (this.pageInfo.promotionType === 2 && this.isTxOline) {
                list = list.length > 0 ? [list[0]] : [];
                this.$store.dispatch('pages/setData', {
                  isTxOline: true
                });
              } else {
                this.$store.dispatch('pages/setData', {
                  isTxOline: false
                });
              }
              if (!this.popupStatus) {
                // 视频号弹窗，状态控制，如果为关闭状态那么，不走挽留弹出流程
                list = [];
              }

              // 通过卡包进入并且有优惠金额时
              if (['1008'].includes(source) && discountAmount) {
                // 挽留列表中过滤掉与卡包优惠金额相等的数据
                list = list.filter(item => item.discountAmount > Number(discountAmount));
                // 聚合页的优惠金额小于等于当前卡包金额时，清除聚合页配置信息
                if (pageModule?.aggregatePage && pageModule?.aggregatePage?.discountAmount <= Number(discountAmount)) {
                  this.$store.dispatch('pages/setData', {
                    groupsInfo: null
                  });
                }
              } else if (['1026', '1004', '1025', '1031'].includes(source)) {
                Object.assign(this.query, {
                  discountAmount: pageModule?.aggregatePage?.discountAmount || 0
                });
                // 展示优惠提示栏
                this.beforeAnimateEnd = true;
                list = [];
              }
              // console.log('挽留列表->', list);
              // console.log('聚合页->', pageModule?.aggregatePage?.discountAmount);
              this.$store.dispatch('pages/setData', {
                exitPopupList: list,
                exitPopupIndex: 0
              });
            }
          } catch (e) {
            console.warn(e);
          }
        }
      }).catch(() => {
        // 使用js错误都会触发catch
        HTTP_RETRY_COUNT++;
        // 尝试100次
        if (HTTP_RETRY_COUNT < 100) {
          this.getPageDetailTimeout = setTimeout(() => {
            this.getPageDetail(this.query);
          }, HTTP_RETRY_COUNT * 300);
        }
      });
    },
    //  获取商品详情数据
    getProductDetail(pageDetail) {
      this.$store.dispatch('product/getProductDetail', {
        pageId: pageDetail.id,
        productId: pageDetail.productId,
        source: this.query.source
      }).then((res) => {
        // 成功之后，重置计数
        HTTP_RETRY_COUNT = 1;
        const { productDetail } = res;
        if (!res) {
          // productStatus	int	0-已下架；1-已上架
          this.isDeleted = true;
          this.isLoad = true;
        } else {
          // 设置分享海报信息
          this.shareData = {
            originalPrice: productDetail.originalPrice,
            productMainPic: productDetail.productMainPic,
            pageId: this.query.pageId,
            productTitle: this.pageInfo.pageProductTitle,
            sellingPrice: this.pageInfo.pagePrice
          };
          this.isLoad = true;

          // 获取商品可使用的优惠券
          this.getCouponList();
          // 获取可以发放的优惠券列表
          this.getSendCoupon();
          // 获取其他信息
          this.getProductOther();

          // 数据埋点
          this.$XTrack('push', {
            customerId: this.pageInfo.storeId,
            pageId: this.query.pageId,
            productId: this.pageInfo.productId
          });
          // 有数上报
          $sr.track('browse_sku_page', {
            'sku': {
              sku_id: this.query.pageId,
              sku_name: this.pageInfo.pageProductTitle
            },
            'spu': {
              spu_id: this.query.pageId,
              spu_name: this.pageInfo.pageProductTitle
            }
          });
        }
      }).catch(() => {
        HTTP_RETRY_COUNT++;
        if (HTTP_RETRY_COUNT < 100) {
          this.getProductDetailTimeout = setTimeout(() => {
            this.getProductDetail(pageDetail);
          }, HTTP_RETRY_COUNT * 300);
        }
      });
    },
    // 获取商品其它信息
    async getProductOther() {
      setTimeout(() => {
        this.getBrandInfo(); // 获取商品信息后 获取品牌信息
        this.getConfigData(); // 获取商品信息后 获取客服
        // 页面加载之后，向数据团队上报特定消息
        this.$store.dispatch('pages/fetchReportViewAttr', this.query).catch(() => {
          // 万一错误了，再试一次
          this.$store.dispatch('pages/fetchReportViewAttr', this.query);
        });
      }, 500);

      // 处理聚合页过来的逻辑
      if (['groups', '1018', '1019', '1030'].includes(this.query.source)) {
        this.getGroupsInfo();
      } else if (['1030'].includes(this.query.source)) {
        if (this.query.groupsType === 'advertising') {
          this.groupsVisible = true;
        } else {
          // console.log(111111111);
          this.showBuy();
        }
      }
    },
    //  获取店铺信息
    async getStoreInfo() {
      const { source, pageId, sourcePageId } = this.query;
      const payload = {
        storeId: this.pageInfo.storeId,
        sourcePageId,
        pageId,
        source
      };
      await this.$store.dispatch('product/getStoreInfo', payload).then((res) => {
        this.storeInfo = res.data;
      }).then(() => {
        // 跳转到表单位置
        if (['1023', '1025', '1026'].includes(source)) {
          // console.log(333333);
          this.showBuy();
        }
        this.getGiftInfo();
      }).catch(() => {
        // 跳转到表单位置
        if (['1023', '1025', '1026'].includes(source)) {
          // console.log(444444);
          this.showBuy();
        }
      });
    },
    // 配置页面历史状态
    setPreviousPath() {
      const previous = {
        // 0，初始 1，投放页；2，挽留弹窗口，3，挽留页面，12 视频号 5，挽留弹窗但是页面下架
        previousStatus: 12,
        previousPath: '/pages/advertising/index'
      };
      // 更新store访问数据
      if (['groups', '1030'].includes(this.query.source)) {
        previous.previousStatus = 3;
      } else if (['1018', '1019'].includes(this.query.source)) {
        previous.previousStatus = 4;
      } else if (['1033'].includes(this.query.source)) {
        previous.previousStatus = 5;
      } else {
        // 非聚合页过来时，需要重置参数
        previous.previousQuery = this.query;
        // 通过url参数值进来的状态值
        if (this.query.previousStatus) {
          previous.previousStatus = +this.query.previousStatus;
          // 直接展示挽留弹窗
          if (previous.previousStatus === 2) {
            console.log('展示挽留弹框');
            previous.payCancelTwoVisible = true;
          }
        }
        if (this.groupsInfo) {
          // 用户挽留页信息
          const { publicityType, pageId } = this.groupsInfo;
          this.$XTrack('GroupsPageInfo', {
            type: publicityType,
            id: pageId
          });
        }
      }
      if (this.clearStoreStorage) {
        this.$store.dispatch('pages/setData', previous);
      }
      // 如果是半屏打开，这时没有缓存，重新获取页面数据
      const { apiCategory } = wx.getEnterOptionsSync();
      if (apiCategory === 'embedded') {
        this.getPageDetail(this.query);
      }
    },
    // 获取客服按钮信息
    getConfigData() {
      this.$http({
        url: '/account/consulter/iu/app/detail',
        report: true,
        alarm: true,
        data: {
          storeId: this.pageInfo.storeId
        }
      }).then(res => {
        this.shareCustomerData = res.data || {};
        this.sessionFrom = `【商品推广页】 页面标题：${this.pageInfo.pageName}；页面ID：${this.pageInfo.id}`;
      });
    },
    // 获取商品可使用的优惠券
    async getCouponList() {
      await this.$store.dispatch('product/getCouponList', {
        storeId: this.pageInfo.storeId,
        productId: this.pageInfo.productId,
        query: this.query || {}
      }).then(() => {
        this.isGetCouponList = true;
      }).catch(() => {
        this.isGetCouponList = true;
      });
      if (this.isStay) {
        this.showBuy();
      }
    },
    //  获取品牌
    getBrandInfo() {
      // 已有数据，不再请求
      if (this.brandInfo) return false;
      this.$http({
        login: true,
        url: '/product/brand/app/detail',
        method: 'get',
        report: false,
        data: {
          brandId: this.pageInfo.brandId
        }
      }).then(res => {
        this.brandInfo = res.data ? res.data : null;
      }).catch(err => {
        console.log(err);
      });
    },
    /**
     * 创建Observer
     * */
    createObserver() {
      ObserverForm = uni.createIntersectionObserver(this);
      ObserverForm
        .relativeToViewport()
        .observe('#form-order', (res) => {
          this.hideFooter = res.intersectionRatio > 0; // 相交区域占目标节点的布局区域的比例
          if (res.intersectionRatio > 0 && !this.StartShowFrom) {
            this.StartShowFrom = true;
            this.$XTrack('StartShowFrom', 'footer');
          }
        });
    },
    //  打开分享弹框
    openShareVisible() {
      this.shareVisible = true;
    },
    // 关闭分享海报
    closePoster() {
      this.posterVisible = false;
    },
    // 组件生成分享海报传值
    shareImage(res) {
      this.posterVisible = true;
      this.posterLoad = true;
      this.posterImage = res.posterImage;
      this.shareVisible = false;
    },
    //  点击保存海报
    saveImage() {
      uni.saveImageToPhotosAlbum({
        filePath: this.posterImage, //    图片文件路径，可以是临时文件路径也可以是永久文件路径，不支持网络图片路径
        success: () => {
          uni.showToast({
            title: '保存成功',
            duration: 2000
          });
          this.posterVisible = false;
        },
        fail: () => {
          uni.showToast({
            title: '保存失败',
            duration: 2000
          });
        }
      });
    },
    onStore() {
      uni.navigateTo({
        url: `/packages/store/index?storeId=${this.productInfo.storeId}`
      });
    },
    // 回到顶部
    scrollTop() {
      uni.pageScrollTo({
        scrollTop: 0,
        duration: 300
      });
      this.$XTrack('toTopClickEvent'); // 回到顶部按钮点击 上报
    },
    onReachBottom() {
      this.isShowCompany = true;
    },
    // 监听页面滚动，处理顶部导航栏以及marquee
    handlePageScroll(scrollTop) {
      // pageScrollTop变量不要在data中定义，这样值变化的时候不会触发视图渲染
      pageScrollTop = scrollTop;
      if (!this.scrolled) {
        this.$XTrack('pageScrolledEvent'); // 滚动事件埋点上报
        this.scrolled = true; // 滚动过
      }
    },
    // 获取下单模块距离顶部距离
    async showBuy(res) {
      // console.log('showBuy');
      const placement = res || '';
      let position = 'bottom';
      // if (this.pageModule?.formStyle && this.pageModule.formStyle.value === 2) {
      //   // 定位到底部表单
      //   this.scrollToFormOrder();
      // } else {
      //   // 展示悬浮表单
      //   this.isShowFormOrder = true;
      //   position = 'fixed';
      // }
      // 展示悬浮表单
      this.isShowFormOrder = true;
      position = 'fixed';
      // 中间购买按钮点击跳转到选择商品数量/规格 埋点上报
      this.$XTrack('middleBuyClick', {
        placement,
        position
      });
    },
    showOrderModal() {
      this.isShowFormOrder = true;
      this.$XTrack('middleSkuClick');
    },
    // 滚动到输入订单信息位置
    scrollToFormOrder() {
      // 选中节点的属性
      this.boundingClientRectSync('#form-order').then(res => {
        uni.pageScrollTo({
          scrollTop: (res.top || 0) + pageScrollTop - (this.windowInfo.statusBarHeight + 48),
          duration: 0
        });
      });
    },
    // 同步获取元素的属性
    boundingClientRectSync(selector) {
      return new Promise((resolve, reject) => {
        uni.createSelectorQuery().select(selector).boundingClientRect((rect) => {
          resolve(rect || {});
        }).exec();
      });
    },
    // 进入全屏
    fullscreenchange(fullScreen) {
      // 值true为进入全屏，false为退出全屏
      this.inFullScreen = !fullScreen;
    },
    // 点击挽留弹窗确认回调
    async onDiscountPay() {
      this.isShowExitPopup = false;
      if (this.isStay) {
        this.getPageDetail(this.query);
      }
      this.$store.dispatch('pages/setData', {
        comboIndex: 0,
        isConfirmPopup: true,
        payCancelTwoVisibleAgain: true
      });
      // console.log('使用优惠支付', this.query);
      this.$XTrack('StartShowFrom', 'fixed');
      // 展示优惠提示栏
      setTimeout(() => {
        this.beforeAnimateEnd = true;
      }, 300);
    },
    // 聚合弹框信息
    getGroupsInfo() {
      this.$http({
        url: '/product/page/app/aggregate/info',
        data: {
          pageId: this.query.pageId
        }
      }).then((result) => {
        const data = result.data;
        if (data) {
          if (this.query.groupsType === 'advertising') {
            this.groupsVisible = true;
          } else {
            // console.log(66666);
            this.showBuy();
          }
          this.groupsDetail = data;
        }
      });
    },
    // 聚合弹框关闭
    handleGroupsModal() {
      this.onCustomEvent();
      this.$store.dispatch('message/requestSubscribeMessage', {
        subscribeType: 1,
        subscribeNode: 101,
        subscribeContent: this.query.pageId,
        pageId: this.query.pageId,
        storeId: this.pageInfo.storeId
      });
      // console.log(7777);
      this.showBuy();
    },
    // 倒计时更新
    handleCountdownChange(res) {
      this.$store.dispatch('pages/setData', {
        animateCountdownData: res
      });
      if (res.remain <= 0) {
        this.$store.dispatch('pages/setData', {
          animateCountdownData: false
        });
      }
    },
    // 超时
    handleRetryPage() {
      this.isTimeOut = false;
      this.getPageDetail(this.query);
    },

    // 获取可领取的优惠券
    getSendCoupon() {
      const { pageId } = this.query;
      const { storeId, productId } = this.pageInfo;
      this.$store.dispatch('product/getCouponSendList', {
        source: 1,
        pageId,
        storeId,
        productId
      }).then((coupon) => {
        this.couponSendList = coupon;
        if (this.payCancelTwoVisible || !coupon) {
          this.couponDrawerVisible = false;
        }
      }).finally(() => {
        this.couponLoaded = true;
      });
    },

    // 点击中部按钮和底部按钮
    handleClickBuyButton() {
      this.couponSendList = null;
      // console.log(8888);
      this.showBuy();
    },
    // 关闭优惠券弹框
    onCloseCustomEvent() {
      // 订阅消息
      this.$store.dispatch('message/requestSubscribeMessage', {
        subscribeType: 1,
        subscribeNode: 100,
        subscribeContent: this.query.pageId,
        storeId: this.pageInfo.storeId,
        pageId: this.query.pageId
      });
      // 允许页面滑动并隐藏配置的优惠券弹框
      this.couponDrawerVisible = false;
      this.superSubsidyVisible = false;
    },
    // 领取优惠券并下单
    onCustomEvent() {
      this.couponDrawerVisible = false;
      this.$store.dispatch('product/setData', {
        isSendCoupon: true,
        couponSend: null
      });
      // 投放页的优惠券列表数据刷新
      this.getCouponList();
    },
    // 获取支付有礼配置信息
    getGiftInfo() {
      this.$http({
        error: false,
        url: '/marketing/gift/app/count',
        data: {
          productId: this.pageInfo.productId,
          storeId: this.pageInfo.storeId
        }
      }).then((res) => {
        this.productGiftInfo = res.data;
      });
    },
    handleCloseSubsidyModal() {
      this.superSubsidyVisible = false;
      this.couponDrawerVisible = false;
    },
    showEvoke() {
      if (this.topPicks && this.topPicks.evokeStatus === 1) {
        this.evokeTimer = setTimeout(() => {
          if (!this.isShowFormOrder && this.orderCountInfo.payCount === 0) {
            this.evokeVisible = true;
          }
        }, this.topPicks.evokeTime * 1000 || 30000);
      }
    },
    // 跳转店铺资质页
    handleToBusiness() {
      const { appName } = $config;
      const { storeId, storeName } = this.storeInfo;
      const { pageId } = this.query;
      uni.navigateTo({
        url: `/packages/store/business?storeId=${storeId}&storeName=${storeName || appName}&pageId=${pageId}&productId=${this.pageInfo.productId}`
      });
    },
    // 获取辅站小程序最近下单
    getOrderLast() {
      this.$http({
        url: '/order/order/app/latest',
        report: true,
        alarm: true
      }).then(res => {
        // console.log(res, 6666666);
        const orderId = res.data;
        if (orderId) {
          const params = {
            orderId: orderId
          };
          this.$http({
            login: true,
            url: '/order/order/app/detail',
            method: 'get',
            data: params
          }).then(res => {
            uni.reLaunch({
              url: `/packages/order/detail/index?orderId=${orderId}`,
              complete() {
                setTimeout(() => {
                  uni.hideLoading();
                }, 1000);
              }
            });
          });
        }
      });
    },
    // 查询用户是否下过单
    async getOrderCount() {
      await this.$http({
        login: true,
        error: false,
        url: '/order/app/order/count',
        data: {
          pageId: this.query.pageId
        }
      }).then((res) => {
        this.$store.dispatch('pages/setData', {
          orderCountInfo: res.data
        });
      }).catch(() => {
      });
    }
  }
};
</script>
<style lang="scss" scoped>
@import 'styles/put.scss';

.all-page{
  --padding: 24px;
}

.is-new-template{
  .bottom-placeholder{
    height: 280px;
  }
}

.is-template-3{
  .goods-content{
    padding-right: var(--padding);
    padding-left: var(--padding);
  }

  .gray-box{
    background: #F8F8F8;
  }
}

.pop_order-info{
  z-index: 999; height: 85vh; width: 100%; background: #F7F8FA; border-radius: 20px 20px 0 0; overflow: hidden; position: fixed; top: 15vh; transition: top .3s ease; display: flex; flex-direction: column;
  .pop_close{ z-index: 100; position: absolute; top: 30px; right: 24px; width: 54px; height: 54px; border: 1px solid #CFCFCF; border-radius: 54px; display: flex; align-items: center; justify-content: center; }
  .pop_info{ flex: 1; overflow: auto; }
}

.gray-box{
  background: #F7F8FA;
  border-radius: 20px;
  padding: 0 20px;
  margin: 20px var(--padding) 0;

  .li-item{
    padding: 28px 0;
    & +.li-item{
      border-top: 1px solid #EBEDF0;
    }
  }
}

.new-footer{
  z-index: 11; position: fixed; left: 0; bottom: 0; width: 100%;
  &.is-hide { opacity: 0 !important; visibility: hidden !important; }
}

.company-info {
  background: #fff;
  padding: 20px;
  font-size: 22px;
  color: #999;
  text-align: center;
  margin-bottom: 100px;
  .store-name {
    text-decoration: underline;
  }
}
.page-placeholder{
  height: 108px;
  margin-top: env(safe-area-inset-bottom);
}
</style>
